<%@ page import="com.zafu.entity.MessageInfo" %>
<%@ page import="com.zafu.dao.MessageBean" %>
<%@ page import="java.net.URLDecoder" %><%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2024/12/24
  Time: 13:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String name = request.getParameter("Message_Name");
    if(name != null && name.length() > 0)
        name = URLDecoder.decode(name, "UTF-8");

    String image = request.getParameter("Message_Image");
    if(image != null && image.length() > 0)
        image = URLDecoder.decode(image, "UTF-8");

    String message = request.getParameter("Message");
    if(message != null && name.length() > 0)
        message = URLDecoder.decode(message, "UTF-8");

    String date = request.getParameter("Message_Date");
    if(date != null && date.length() > 0)
        date = URLDecoder.decode(date, "UTF-8");

    Integer id = null;
    String idParam = request.getParameter("count");
    if (idParam != null && idParam.length() > 0) {
        try {
            id = Integer.parseInt(idParam);
        } catch (NumberFormatException e) {
            // 如果转换失败，可以记录日志或抛出异常
            System.out.println("Invalid id: " + idParam);
        }
    }

    MessageInfo info = new MessageInfo(name, image, message, date, id);
    MessageInfo info1 = new MessageInfo("111", "111", "111", "111", 1);
    MessageBean bean = new MessageBean();
    int count = bean.Add_Message(info);
    out.println("插入成功");
%>
